package jp.go.aist.six.test.util.orm.inheritance;

import jp.go.aist.six.util.persist.AbstractPersistable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;



/**
 * @author  Akihito Nakamura, AIST
 * @version $Id: ContainerX.java 203 2010-12-02 03:03:07Z nakamura5akihito $
 */
public class ContainerX
    extends AbstractPersistable<String>
    implements Iterable<AbstractA>
{

    private Collection<AbstractA>  _elements = new ArrayList<AbstractA>();



    /**
     */
    public ContainerX()
    {
    }


    /**
     */
    public ContainerX(
                    final Collection<? extends AbstractA> elements
                    )
    {
        setElement( elements );
    }



    /**
     */
    public boolean addElement(
                    final AbstractA element
                    )
    {
        return _elements.add( element );
    }


    public void setElement(
                    final Collection<? extends AbstractA> elements
                    )
    {
        if (elements != _elements) {
            _elements.clear();
            if (elements != null  &&  elements.size() > 0) {
                _elements.addAll( elements );
            }
        }
    }


    public Collection<AbstractA> getElement()
    {
        return _elements;
    }



    public Iterator<AbstractA> iterator()
    {
        return _elements.iterator();
    }



    @Override
    public String toString()
    {
        return "ContainerX[" + getElement() + "]";
    }

}
// ContainerX

